<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- Some extra functions to extend Data.Map</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Data.FiniteMap</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-4"></span><span>        </span><span class="annot"><a href="GHC.Data.FiniteMap.html#insertList"><span class="hs-identifier">insertList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-5"></span><span>        </span><span class="annot"><a href="GHC.Data.FiniteMap.html#insertListWith"><span class="hs-identifier">insertListWith</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-6"></span><span>        </span><span class="annot"><a href="GHC.Data.FiniteMap.html#deleteList"><span class="hs-identifier">deleteList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-7"></span><span>        </span><span class="annot"><a href="GHC.Data.FiniteMap.html#foldRight"><span class="hs-identifier">foldRight</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.FiniteMap.html#foldRightWithKey"><span class="hs-identifier">foldRightWithKey</span></a></span><span>
</span><span id="line-8"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.html#"><span class="hs-identifier">Data.Map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier">Map</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.html#"><span class="hs-identifier">Data.Map</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Map</span></span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span id="local-6989586621680774340"><span id="local-6989586621680774341"><span class="annot"><a href="GHC.Data.FiniteMap.html#insertList"><span class="hs-identifier hs-type">insertList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621680774341"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680774341"><span class="hs-identifier hs-type">key</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680774340"><span class="hs-identifier hs-type">elt</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774341"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774340"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774341"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774340"><span class="hs-identifier hs-type">elt</span></a></span></span></span><span>
</span><span id="line-16"></span><span id="insertList"><span class="annot"><span class="annottext">insertList :: forall key elt.
Ord key =&gt;
[(key, elt)] -&gt; Map key elt -&gt; Map key elt
</span><a href="GHC.Data.FiniteMap.html#insertList"><span class="hs-identifier hs-var hs-var">insertList</span></a></span></span><span> </span><span id="local-6989586621680774295"><span class="annot"><span class="annottext">[(key, elt)]
</span><a href="#local-6989586621680774295"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621680774294"><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774294"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Map key elt -&gt; (key, elt) -&gt; Map key elt)
-&gt; Map key elt -&gt; [(key, elt)] -&gt; Map key elt
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680774292"><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774292"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680774291"><span class="annot"><span class="annottext">key
</span><a href="#local-6989586621680774291"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680774290"><span class="annot"><span class="annottext">elt
</span><a href="#local-6989586621680774290"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">key -&gt; elt -&gt; Map key elt -&gt; Map key elt
forall k a. Ord k =&gt; k -&gt; a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#insert"><span class="hs-identifier hs-var">Map.insert</span></a></span><span> </span><span class="annot"><span class="annottext">key
</span><a href="#local-6989586621680774291"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">elt
</span><a href="#local-6989586621680774290"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774292"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774294"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">[(key, elt)]
</span><a href="#local-6989586621680774295"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span id="local-6989586621680774330"><span id="local-6989586621680774331"><span class="annot"><a href="GHC.Data.FiniteMap.html#insertListWith"><span class="hs-identifier hs-type">insertListWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621680774331"><span class="hs-identifier hs-type">key</span></a></span><span>
</span><span id="line-19"></span><span>               </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680774330"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774330"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774330"><span class="hs-identifier hs-type">elt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680774331"><span class="hs-identifier hs-type">key</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680774330"><span class="hs-identifier hs-type">elt</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-21"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774331"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774330"><span class="hs-identifier hs-type">elt</span></a></span><span>
</span><span id="line-22"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774331"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774330"><span class="hs-identifier hs-type">elt</span></a></span></span></span><span>
</span><span id="line-23"></span><span id="insertListWith"><span class="annot"><span class="annottext">insertListWith :: forall key elt.
Ord key =&gt;
(elt -&gt; elt -&gt; elt) -&gt; [(key, elt)] -&gt; Map key elt -&gt; Map key elt
</span><a href="GHC.Data.FiniteMap.html#insertListWith"><span class="hs-identifier hs-var hs-var">insertListWith</span></a></span></span><span> </span><span id="local-6989586621680774285"><span class="annot"><span class="annottext">elt -&gt; elt -&gt; elt
</span><a href="#local-6989586621680774285"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680774284"><span class="annot"><span class="annottext">[(key, elt)]
</span><a href="#local-6989586621680774284"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621680774283"><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774283"><span class="hs-identifier hs-var">m0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Map key elt -&gt; (key, elt) -&gt; Map key elt)
-&gt; Map key elt -&gt; [(key, elt)] -&gt; Map key elt
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680774282"><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774282"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680774281"><span class="annot"><span class="annottext">key
</span><a href="#local-6989586621680774281"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680774280"><span class="annot"><span class="annottext">elt
</span><a href="#local-6989586621680774280"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(elt -&gt; elt -&gt; elt) -&gt; key -&gt; elt -&gt; Map key elt -&gt; Map key elt
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; k -&gt; a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#insertWith"><span class="hs-identifier hs-var">Map.insertWith</span></a></span><span> </span><span class="annot"><span class="annottext">elt -&gt; elt -&gt; elt
</span><a href="#local-6989586621680774285"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">key
</span><a href="#local-6989586621680774281"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">elt
</span><a href="#local-6989586621680774280"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774282"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774283"><span class="hs-identifier hs-var">m0</span></a></span><span> </span><span class="annot"><span class="annottext">[(key, elt)]
</span><a href="#local-6989586621680774284"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span id="local-6989586621680774324"><span id="local-6989586621680774325"><span class="annot"><a href="GHC.Data.FiniteMap.html#deleteList"><span class="hs-identifier hs-type">deleteList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621680774325"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680774325"><span class="hs-identifier hs-type">key</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774325"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774324"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774325"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774324"><span class="hs-identifier hs-type">elt</span></a></span></span></span><span>
</span><span id="line-26"></span><span id="deleteList"><span class="annot"><span class="annottext">deleteList :: forall key elt. Ord key =&gt; [key] -&gt; Map key elt -&gt; Map key elt
</span><a href="GHC.Data.FiniteMap.html#deleteList"><span class="hs-identifier hs-var hs-var">deleteList</span></a></span></span><span> </span><span id="local-6989586621680774275"><span class="annot"><span class="annottext">[key]
</span><a href="#local-6989586621680774275"><span class="hs-identifier hs-var">ks</span></a></span></span><span> </span><span id="local-6989586621680774274"><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774274"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Map key elt -&gt; key -&gt; Map key elt)
-&gt; Map key elt -&gt; [key] -&gt; Map key elt
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(key -&gt; Map key elt -&gt; Map key elt)
-&gt; Map key elt -&gt; key -&gt; Map key elt
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">key -&gt; Map key elt -&gt; Map key elt
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#delete"><span class="hs-identifier hs-var">Map.delete</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map key elt
</span><a href="#local-6989586621680774274"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">[key]
</span><a href="#local-6989586621680774275"><span class="hs-identifier hs-var">ks</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span id="local-6989586621680774314"><span id="local-6989586621680774315"><span id="local-6989586621680774316"><span class="annot"><a href="GHC.Data.FiniteMap.html#foldRight"><span class="hs-identifier hs-type">foldRight</span></a></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680774316"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774315"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774315"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774315"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774314"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774316"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774315"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-29"></span><span id="foldRight"><span class="annot"><span class="annottext">foldRight :: forall elt a key. (elt -&gt; a -&gt; a) -&gt; a -&gt; Map key elt -&gt; a
</span><a href="GHC.Data.FiniteMap.html#foldRight"><span class="hs-identifier hs-var hs-var">foldRight</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(elt -&gt; a -&gt; a) -&gt; a -&gt; Map key elt -&gt; a
forall elt a key. (elt -&gt; a -&gt; a) -&gt; a -&gt; Map key elt -&gt; a
</span><a href="../../containers/src/Data.Map.Internal.html#foldr"><span class="hs-identifier hs-var">Map.foldr</span></a></span><span>
</span><span id="line-30"></span><span id="local-6989586621680774308"><span id="local-6989586621680774309"><span id="local-6989586621680774310"><span class="annot"><a href="GHC.Data.FiniteMap.html#foldRightWithKey"><span class="hs-identifier hs-type">foldRightWithKey</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680774310"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774309"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774308"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774308"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774308"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774310"><span class="hs-identifier hs-type">key</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680774309"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680774308"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-31"></span><span id="foldRightWithKey"><span class="annot"><span class="annottext">foldRightWithKey :: forall key elt a. (key -&gt; elt -&gt; a -&gt; a) -&gt; a -&gt; Map key elt -&gt; a
</span><a href="GHC.Data.FiniteMap.html#foldRightWithKey"><span class="hs-identifier hs-var hs-var">foldRightWithKey</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(key -&gt; elt -&gt; a -&gt; a) -&gt; a -&gt; Map key elt -&gt; a
forall key elt a. (key -&gt; elt -&gt; a -&gt; a) -&gt; a -&gt; Map key elt -&gt; a
</span><a href="../../containers/src/Data.Map.Internal.html#foldrWithKey"><span class="hs-identifier hs-var">Map.foldrWithKey</span></a></span><span>
</span><span id="line-32"></span></pre></body></html>